package top.wangxiaomei.ai.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import top.wangxiaomei.ai.domain.Words;
import top.wangxiaomei.ai.other.Abs;

import java.util.HashMap;
import java.util.List;
import java.util.Set;

/**
* @author 23217
* @description 针对表【words】的数据库操作Mapper
* @createDate 2024-08-19 22:53:54
* @Entity generator.domain.Words
*/
public interface WordsMapper extends BaseMapper<Words> {
    @Select("SELECT words.explanation FROM words WHERE words.word = #{word}")
    Set<String> getExplanation(String word);
    @Select("WITH RECURSIVE getex (word, explanation, credibility, depth) AS (SELECT w.word, w.explanation, w.credibility, 1 FROM words AS w WHERE w.word = #{word} UNION ALL SELECT e.word, e.explanation, e.credibility * g.credibility, g.depth + 1 FROM words AS e INNER JOIN getex g ON e.word = g.explanation AND g.depth < 50) SELECT explanation, credibility FROM getex")
    List<Abs> getEx(String word);
}




